<template>
	<view>
		<view class="message-list">
			<view class="item" v-for="(item,index) in messageList" :key="index" @click="toNoticeDetail(item)">
				<view class="acea-row row-middle title">
					<view class="new-doc" v-if="item.onRead!=1"></view>
					<view class="title-text line1">{{item.title || '通知消息'}}</view>
				</view>
				<view class="notice"> 您有一条新的{{ infoType[item.type?item.type:1] }}通知</view>
				<view class="date">{{item.createTime}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {unusedList,inside} from '@/api/message.js'
	export default {
		data() {
			return {
				messageList:[],
				infoType:{
					1: '发布',
					2: '访客',
					3: '匹配',
					4: '推荐',
					5: '收藏',
					6: '关注'
				}
			};
		},
		mounted() {
			this.getMessageRecord();
		},
		methods:{
			// 获取站内信列表
			getMessageRecord(){
				unusedList().then(res=>{
					// console.log(res)
					this.messageList = res.data.list;
				})
			},
			// 
			toNoticeDetail(item){
				let that = this;
				uni.navigateTo({
					url: '/pages/others/messageNoticeDetail/messageNoticeDetail?detail='+JSON.stringify(item),
					success() {
						inside({
							id: item.id
						}).then(res=>{
							that.getMessageRecord();
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.message-list{
	padding: 30rpx;
	.item{
		margin-bottom: 30rpx;
		background: #ffffff;
		border-radius: 10rpx;
		padding: 30rpx;
		.title{
			width: 100%;
			font-size: 30rpx;
			font-weight: 400;
			color: rgba(0, 0, 0, 1);
			.new-doc{
				width: 12rpx;
				height: 12rpx;
				background: #EE212D;
				border-radius: 50%;
				margin-right: 12rpx;
			}
			.title-text{
				width: calc(100% - 40rpx);
			}
		}
		.notice{
			width: 100%;
			font-size: 26rpx;
			font-weight: 400;
			line-height: 64rpx;
			color: rgba(128, 128, 128, 1);
		}
		.date{
			// margin-top: 36rpx;
			font-size: 26rpx;
			font-weight: 400;
			color: rgba(166, 166, 166, 1);
		}
	}
}
</style>
